<?php
if(isset($_REQUEST['cate_id'])){
		$v_category_id=$_REQUEST['cate_id'];
}
if(isset($_REQUEST['agency_id'])){
		$v_agency_id=$_REQUEST['agency_id'];
}

if(isset($_REQUEST['offset'])){
	$v_offset=$_REQUEST['offset'];
}
else
	$v_offset=1;
$v_limit = CONST_LIMIT_AF_PAGE;
	
$v_type = 3;
if(isset($_REQUEST['v_type'])){
	$v_type = $_REQUEST['v_type'];
}

if(isset($_REQUEST['page'])){
	$page=$_REQUEST['page'];
}
else
	$page=1;
	

if(_is_sqlserver()){	
//Lay tong so TTHC thuoc linh va co quan hanh chinh da cho
	$cmd = @mssql_init("ONEGATE_AFCountByCateAgency",$conn);
	@mssql_bind($cmd,"@p_agency_id",$v_agency_id,SQLINT4);	
	@mssql_bind($cmd,"@p_cate_id",$v_category_id,SQLINT4);
	$resoult = @mssql_execute($cmd);
	$arr_resoult = _get_row_to_array($resoult); 
	@mssql_free_result($resoult);
	$v_total_af_count = $arr_resoult['0']['0'];
	$v_cate_name = $arr_resoult['0']['1'];
	$v_agency_name = $arr_resoult['0']['2'];
	
	$pager  = Pager::getPagerData($v_total_af_count, $v_limit, $page);
	$page   = $pager->page;
  	$offset = $pager->offset +1; 
  	$limit = $pager->limit;

	//Lay danh sach bai viet ra recordset
	$cmd = @mssql_init("ONEGATE_AFGetAllByAgencyCate",$conn);
	@mssql_bind($cmd,"@p_cate_id",$v_category_id,SQLINT4);	
	@mssql_bind($cmd,"@p_agency_id",$v_agency_id,SQLINT4);	
	@mssql_bind($cmd,"@offset", $offset,SQLINT4);	
	@mssql_bind($cmd,"@limit",$limit,SQLINT4);		
	$rs_all_af = @mssql_execute($cmd);
	$arr_all_af = _get_row_to_array($rs_all_af); 
	@mssql_free_result($rs_all_af);
}?>